# Contributor: Hugo Wang <w@mitnk.com>
# Maintainer: Hugo Wang <w@mitnk.com>
pkgname=cicada
pkgver=0.9.29
pkgrel=3
pkgdesc="A bash-like Unix shell"
url="https://github.com/mitnk/cicada"
# s390x and riscv64 blocked by cargo
arch="all !s390x !riscv64"
license="MIT"
depends="ncurses-terminfo-base"
makedepends="sqlite-dev cargo"
checkdepends="xz"
install="$pkgname.post-install $pkgname.pre-deinstall"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/mitnk/cicada/archive/v$pkgver.tar.gz
	ulimit.patch
	unbundle-sqlite.patch
	"

prepare() {
	default_prepare
	cargo fetch --locked
}

build() {
	export CARGO_PROFILE_RELEASE_LTO=true
	export CARGO_PROFILE_RELEASE_PANIC=abort
	export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
	export CARGO_PROFILE_RELEASE_OPT_LEVEL=s
	cargo build --frozen --release
}

check() {
	cargo test --frozen --release --bins
}

package() {
	install -Dm755 target/release/cicada -t "$pkgdir"/usr/bin
	install -Dm644 docs/*.md -t "$pkgdir"/usr/share/doc/$pkgname
}

sha512sums="
cf5a50db78d0a6d67850623ce556d0c2b47c528ed94078684ef3afbe9015795faa6bd67de623234c9ab159b76fa1ba7fbf872f53a528882eb97512d64a2a507f  cicada-0.9.29.tar.gz
5a68a11b8b91c0536655ed0af959db4d051ea6ecfeff80e7b335c53395321d5cc264d5485ac50c0d986f31a4c56e0d41624dfc2930cca51650ec0b4f8faa5f9a  ulimit.patch
6a92f6c19d2cf9bd09621528c6ae32bfe0f1518c37e8e4ac5242f99a2f544ed2730ea2c41d2b7c57f7e33704fdde3db9ba19572663766cafb1a0dd4d80a29193  unbundle-sqlite.patch
"
